import { Component, Input, OnInit } from '@angular/core';
import { AbstractControl, FormGroup } from '@angular/forms';

@Component({
    selector: 'app-form-input-error',
    templateUrl: './FormInputError.component.html',
})
export class FormInputErrorComponent implements OnInit {
    @Input() formControlId: string;
    @Input() formGroupReference: FormGroup;
    @Input() useUnitValidate = false;
    public errorsList = [];
    public abstractControl: AbstractControl;
    public externalControl: AbstractControl;

    constructor() {}

    ngOnInit() {
        this.abstractControl = this.formGroupReference.get(this.formControlId);
        if (!this.useUnitValidate) return;
        this.externalControl = this.formGroupReference;
    }
}
